package com.jinsi.config;

import com.jinsi.handle.LoginHandler;
import com.jinsi.handle.TestHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

// 拦截器的配置类
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Autowired
    private LoginHandler loginHandler;

    @Autowired
    private TestHandler testHandler;


    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginHandler)
                .addPathPatterns("/**") // 添加拦截的路径
                .excludePathPatterns(// 放行路径
                        "/login", // 放行登录
                        "/kaptcha", // 放行验证码
                        "/**/login.html", // 放行静态页面
                        "/**/*.js", // 放行js
                        "/**/*.css" // 放行css
                );


        registry.addInterceptor(testHandler)
                .addPathPatterns("/**");



    }
}
